package com.lk.wz.action.user;

import java.io.IOException;
import java.io.Writer;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.lk.wz.dao.UserDao;
import com.lk.wz.dao.impl.UserDaoImpl;

public class ValidateUserNameAction extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		String userName=request.getParameter("name");
		UserDao userDao=new UserDaoImpl();
		int count=userDao.validateUserName(userName);
		Writer out=response.getWriter();
		String result=String.valueOf(count);
		System.out.println(result);
		out.write(result);
		out.close();
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(req, resp);
	}
	
}
